package butines.game;

import java.util.LinkedList;
import java.util.List;

import butines.game.image.ColorPalleta;

public class Team {
	
	private ColorPalleta color;
	private List<Unit> units = new LinkedList<Unit>();
	
	public Team(ColorPalleta color) {
		this.color = color;
	}

	public ColorPalleta getColor() {
		return color;
	}

	public void setColor(ColorPalleta color) {
		this.color = color;
	}

	public List<Unit> getUnits() {
		if (units == null) {
			units = new LinkedList<Unit>();
		}
		return units;
	}

	public void setUnits(List<Unit> units) {
		this.units = units;
	}

	public void addUnit(Unit unit) {
		Team teamUnit = unit.getTeam();
		if (teamUnit != null) {
			teamUnit.removeUnit(unit);
		}
		getUnits().add(unit);
		unit.setTeam(this);
	}

	public void removeUnit(Unit unit) {
		getUnits().remove(unit);
		unit.setTeam(null);
	}
	
}
